<?php
/**
 *权限调用类
 *@author sulwan@126.com
 *@date 2009-11-20
 */

 class information extends Application{
    public $Classlist;

 public function __construct() {
    parent::__construct();
 }

/**
 *查看有哪些资讯分类
 */
public function informationTreeSort(){
	$data = getCache(INFORMATION,'informationTree');
	if(empty($data)) {
		unset($data);
		$this->informationclassSort();
		$temp = $this->Classlist->getTreeList();
		foreach ($temp as $k => $v) {					//添加深度
			$data[] = $v->obj;
			$data[$k]['depth'] = $v->depth;
			$fields[] = 'pid = '.$data[$k]['id'];
			$data[$k]['Children'] = $this->seachFields($fields);
			$data[$k]['state'] = $data[$k]['Children']?$data[$k]['Children']:'open';
			unset($fields);
		}
	}
		setCache(INFORMATION,'informationTree',$data);
        return $data;
}

/**
 *分类数据赋值
 */
public function informationclassSort() {
     $rsList = $this->informationModulegory();
     $this->Classlist = new CCategory();
     $this->Classlist->assign ($rsList, 'id', 'pid', 'taxis');
}

/**
*获取现有模块
*/
public function informationModulegory() {
	$rs = getCache(INFORMATION,'information');
	if(empty($rs)) {
		$sql = "SELECT * FROM #happy_role_column;";
		$rs = $this->_db->getAll($sql);
	}
	setCache(INFORMATION,'information',$rs);
    return $rs;
}

/**
 *检索是否存存在指定字段的指定值
 */
public function seachFields($fields) {
	$where = is_array($fields) ? implode(' AND ', $fields) : $fields;
	$where = empty ($where) ? '' : ' WHERE ' . $where;
    $sql = "SELECT * FROM #happy_role_column";
	$sql .= $where;
    $data = $this->_db->getOne($sql);
	if(!empty($data)) {
		return TRUE;
	}
	return FALSE;
}
}
?>